<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js" type="text/javascript"></script>
</head>
<body>
    <div id="app">
        <!-- 3. 使用组件 -->
        <cpn2></cpn2>
    </div>
    <script>
        // 1. 创建第一个组件构造器对象
        const cpnC1 = Vue.extend({
            template: `
            <div>
                <h2>组件标题1</h2>
                <p>组件段落1</p>
            </div>
            `
        });
        // 1. 创建第二个组件构造器对象
        const cpnC2 = Vue.extend({
            template: `
            <div>
                <h2>组件标题2</h2>
                <p>组件段落2</p>
                <cpn1></cpn1>
            </div>
            `,
            components: {
                cpn1: cpnC1 // 作用域在cpnC2里面
            }
        });
        
        var app = new Vue({
            el: "#app",
            data: {
                message: "hello"
            },
            components: {
                cpn2: cpnC2
            }
        })
    </script>
</body>
</html>